import * as globalTypes from '../../../../mutation-types'
import callCenterConfig from '../../../../api/config/callCenter/sipManage'

export const querySipRefresh = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .querySipRefresh(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const queryRefreshVar = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .queryRefreshVar(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const queryDynamicform = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .queryDynamicform(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const deleteVar = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .deleteVar(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const batchAddGatewaySip = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .batchAddGatewaySip(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const updateGatewayCodes = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .updateGatewayCodes(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const bindGatewayUserExten = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .bindGatewayUserExten(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const advantageSearchSip = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .advantageSearchSip(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const exportSipList = ({ commit }, data) => {
  return callCenterConfig
    .exportSipList(data)
    .then((response) => {
      if (response.Succeed) {
        commit(globalTypes.SET_FILEDOWNLOAD, { path: response.path, isSession: true })
      } else {
      }
    })
    .catch((e) => {
      console.log(e)
      // 'message.default_tips'
    })
}
export const queryBatchSips = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .queryBatchSips(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const batchBindGatewayUserExten = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .batchBindGatewayUserExten(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const batchUpdateCodes = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .batchUpdateCodes(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const updateVar = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .updateVar(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const getGlobalField = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .getGlobalField(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const updateGlobalFieldById = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .updateGlobalFieldById(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const createDynamicform = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .createDynamicform(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const createGlobalField = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .createGlobalField(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const updateGlobalField = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .updateGlobalField(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const deleteGlobalField = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .deleteGlobalField(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const updateDynamicform = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .updateDynamicform(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const delDynamicformById = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .delDynamicformById(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const delGlobalFieldById = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .delGlobalFieldById(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const queryGroups = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .queryGroups(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const enableGroup = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .enableGroup(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const addOrUpdateCallerGroup = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .addOrUpdateCallerGroup(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
export const delGroup = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .delGroup(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}

// export const saveLightServiceNo = ({commit, state, rootState, dispatch}, data) => {
//   return callCenterConfig.saveLightServiceNo(data)
//     .then(response => {
//       return response
//     })
//     .catch(() => {
//       commit(globalTypes.SET_ERROR, 'message.default_tips')
//     })
// }
// export const saveServiceNo = ({commit, state, rootState, dispatch}, data) => {
//   return callCenterConfig.saveServiceNo(data)
//     .then(response => {
//       return response
//     })
//     .catch(() => {
//       commit(globalTypes.SET_ERROR, 'message.default_tips')
//     })
// }
export const updateSchedule1 = ({ commit, state, rootState, dispatch }, data) => {
  return callCenterConfig
    .updateSchedule1(data)
    .then((response) => {
      return response
    })
    .catch(() => {
      commit(globalTypes.SET_ERROR, 'message.default_tips')
    })
}
